VERSION 1.0 CLASS
BEGIN
  MultiUse = -1  'True
  Persistable = 0  'NotPersistable
  DataBindingBehavior = 0  'vbNone
  DataSourceBehavior  = 0  'vbNone
  MTSTransactionMode  = 0  'NotAnMTSObject
END
Attribute VB_Name = "Lines"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False
Option Explicit
'*************************************************************************
'  This source code is provided "as is" and as an unsupported sample of
'  a Microsoft Visual Basic application that incorporates the MapPoint 2002
'  object model and ActiveX control. It can only  be used in accordance with
'  the terms and conditions of the Microsoft MapPoint 2002 and
'  Microsoft Visual Basic End User License Agreements.
'*************************************************************************

Private m_cLines As Collection

Public Sub Add(oLine As SpatialDataImport.Line, Optional vIndexKey As Variant)
    
    If IsEmpty(vIndexKey) = True Then
        m_cLines.Add oLine
    Else
        m_cLines.Add oLine, vIndexKey
    End If
    
End Sub

Public Property Get Count() As Long
    Count = m_cLines.Count
End Property

Public Property Get Item(vIndexKey As Variant) As SpatialDataImport.Line
    Dim oLine As SpatialDataImport.Line
On Error Resume Next
    Set oLine = m_cLines(vIndexKey)
    If oLine Is Nothing Then
        Set Item = Nothing
    Else
        Set Item = oLine
    End If
End Property

Public Property Get NewEnum() As IUnknown
    Set NewEnum = m_cLines.[_NewEnum]
End Property

Public Sub Remove(vIndexKey As Variant)
On Error Resume Next
    m_cLines.Remove vIndexKey
End Sub

Private Sub Class_Initialize()
    Set m_cLines = New Collection
End Sub

Public Sub RenderShapes(omMap As MapPoint.Map)
'**********************************************************************************
    ' Date: 4/3/2001
    ' Abstract: Generates Shape objects for each Line object in the collection.
    ' Assumptions:
    ' Notes:
'**********************************************************************************

    Dim oLine As SpatialDataImport.Line
    Dim omLocArray() As MapPoint.Location
    Dim omLocation As MapPoint.Location
    Dim lLineCount As Long
    Dim lArrayIndex As Long
    
    On Error GoTo errorHandler
    
    'Make sure we have at least one Line.
    lLineCount = m_cLines.Count
    If lLineCount <> 0 Then
    
        'Loop through all the Line objects.
        For Each oLine In m_cLines
        
            'Generate a Location for this Line.
            Set omLocation = oLine.RenderShape(omMap)
            
            'Make sure we got a location.  If so, then add it to our Location array.
            If Not omLocation Is Nothing Then
                
                'Re-Dimension our Location array to make room for the new Location.
                lArrayIndex = lArrayIndex + 1
                ReDim Preserve omLocArray(1 To lArrayIndex)
                
                'Add the returned Location to our Location array.
                Set omLocArray(lArrayIndex) = omLocation
            
            End If
            
        Next oLine
    
        'Create a union of all of the created Lines, and set the map view
        'to show all of them.
        Set omLocation = omMap.Union(omLocArray)
        omLocation.GoTo
        
    End If
    
    Exit Sub
errorHandler:
    MsgBox "Error in RenderShapes" & vbCrLf _
         & "Error Number: " & Err.Number & vbCrLf _
         & "Error Description: " & Err.Description, vbExclamation, App.Title
End Sub
